﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/static/css/common/reset.css" />
    <link rel="stylesheet" href="/static/css/login.css" />
    <link rel="stylesheet" href="/static/css/sweetalert.min.css" />
    <title>登录</title>
</head>
<body>
    <div class="login">
        <section class="header">
            <div class="container">
                <div class="clearfix">
                    <div class="logo fl"><img src="/static/images/logo.png" alt=""></div>
                    <div class="type fl">
                        <h2 id="h2Name">社 团</h2>
                    </div>
                    <!-- <div class="city fl"><span>广州</span><a href="javascript:void(0)">[切换城市]</a></div> -->
                    <div class="search fr">
                        <!--  <a href="javascript:void(0);" class="search-edit"></a> -->
                        <a href="/index.html" class="insideHome">进入首页 >></a>
                    </div>
                </div>
            </div>
        </section>
        <section class="login-content clearfix" style="background-image: url(/static/images/backgroundImage.jpg); background-size: cover; ">
            <div class="loginPart fr">
                <span class="loginPart-title" id="spanLogin">社团账号登录</span>
                <div class="log-content">
                    <form id="formValidate">
                        <input type="text" id="UserType" class="hide" />
                        <input type="text" id="UserName" class="log-f-mail" placeholder="邮箱账号(含手机号码）" />

                        <div class="reg-t-code clearfix mt10">
                            <div class="form_control veriCode">
                                <input type="text" class="required" data-tip="请输入验证码" data-valid="isNonEmpty" data-error="验证码不能为空" placeholder="请输入验证码" id="WeChart" class="log-f-mail" />
                            </div>
                            <img id="valiCode" class="codeImg" src="/api/login/GetValidateCode" alt="验证码" />
                        </div>

                        <input type="password" id="Password" class="log-f-pwd mt10" placeholder="6-16位密码，区分大小写" />
                        <input type="button" class="loginBtn mt20" onclick="Login();" value="登 录" />
                    </form>
                    <p class="log-bottom mt10 clearfix">
                        <a href="forgetPwd.html" class="fl">忘记密码？</a>
                        <a id="aReg" href="#" class="fr">免费注册申请</a>
                    </p>
                    <p id="pOther" class="mt10 colorRed"><a id="aChange" href="javascript:void(0)" class="changeLogin">点击进入企业账号登录 >></a><a id="aChange1" href="javascript:void(0)" class="changeLogin">点击进入代理官登录 >></a></p>
                    <div id="divAgent" class="log-btngroups clearfix hide">
                        <a href="/login.html?type=Personal" class="mt10 colorRed fl">点击进入社团账号登录 >></a>
                        <a href="/login.html?type=Company" class="mt10 colorRed fr">点击进入企业账号登录 >></a>
                        <a href="/login.html?type=Agent" class="mt10 colorRed fr">点击进入代理官登录 >></a>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <div id="divFooter"></div>
</body>
</html>
<script type="text/javascript" src="/static/js/ref/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/static/js/self/common.js"></script>
<script type="text/javascript" src="/static/js/ref/sha512.js"></script>
<script src="/static/js/ref/sweetalert.min.js"></script>
<script src="/static/js/self/util.js"></script>
<script>
    $("#divFooter").load("/wuc/footer.html");

    var param = common.getUrlArgStr();
    if (!common.checkValue(param.type)) {
        param.type = "Personal";
    }
    $("#UserType").val(param.type);
    if (param.type == "Company") {
        $("#h2Name").html("企 业");
        $("#spanLogin").html("企业账号登录");
        $("#aChange").html("点击进入社团账号登录 >>");
        $("#aChange").attr("href", "/login.html?type=Personal");
        $("#aChange1").html("点击进入代理官账号登录 >>");
        $("#aChange1").attr("href", "/login.html?type=Agent");
        $("#aReg").attr("href", "/Company/register.html");
    }
    else if (param.type == "Personal") {
        $("#h2Name").html("社 团");
        $("#spanLogin").html("社团账号登录");
        $("#aChange").html("点击进入企业账号登录 >>");
        $("#aChange").attr("href", "/login.html?type=Company");
        $("#aChange1").html("点击进入代理官账号登录 >>");
        $("#aChange1").attr("href", "/login.html?type=Agent");
        $("#aReg").attr("href", "/Personal/register.html");
    }
    else {
        $("#h2Name").html("代理官");
        $("#spanLogin").html("代理官账号登录");
        $("#aChange").html("点击进入企业账号登录 >>");
        $("#aChange").attr("href", "/login.html?type=Company");
        $("#aChange1").html("点击进入社团账号登录 >>");
        $("#aChange1").attr("href", "/login.html?type=Personal");
        $("#aReg").attr("href", "/Agent/register.html");

    }

    var userLoginType = common.GetUser();
    if (common.checkValue(userLoginType)) {
        common.commonAjax({ type: 'Get', url: '/api/user/CheckUser', sMethod: AfterCheckCompleted });
    }

    function AfterCheckCompleted(ctx) {
        if (ctx == null) {
            common.alertMessage("无数据.");
            return;
        }

        if (ctx.ResponseStr == "N") {
            common.RemoveUser();
            common.alertMessage("登录超时，为保证您的账号安全，请重新登录");
        }
        else if (ctx.ResponseStr == "Y") {
            common.showMessage("您已登录，如需重新登录，请注销后重试", function () { window.location = "/index.html"; });
        }
    }

    function Login() {
        //if (!common.validateForm())
        //    return;
        var email = $('#UserName').val();
        var pass = $('#Password').val();

        if (isBlank(email) || isBlank(pass)) {
            sweetAlert(
              'Oops...',
              '账号或密码不能为空!',
              'error'
            )
            return false;
        }

        var values = common.GetCtrlValues({
            ContentID: "formValidate"
        })

        common.commonAjax({ type: 'Post', url: '/api/user/post', data: values, sMethod: AfterLoginCompleted });
    }
    $("#valiCode").bind("click", function () {
        this.src = "api/Login/GetValidateCode?time=" + (new Date()).getTime();
    });

    function AfterLoginCompleted(ctx) {
        if (ctx == null) {
            common.alertMessage("无数据.");
            return;
        }

        common.PutStorageSession("user", JSON.stringify(ctx.ResponseObj));

        window.location = "/my/myInfo.html";

        //switch (ctx.ResponseObj.UserType) {
        //    case 1:
        //        window.location = "/Company/associate.html";
        //        break;
        //    case 2:
        //        window.location = "/Personal/associate.html";
        //        break;
        //    case 3:
        //        break;
        //}
    }
    if (param.type.toLowerCase() == "agent") {
        common.showMessage("代理官正在完善中，敬请期待", function () {
            window.location = "/org.html?type=Company";
        })
    }


</script>
